<template>
	<view class="flex-col page">
		<view class="flex-col group">
			
			<text class="text_1">{{materialName}}</text>
			<view class="uni-container">
				<uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据">
					<uni-tr style='background-color: rgba(29, 106, 255, 0.0600)'>
						<uni-td>最晚下单时间</uni-td>
						<uni-td>{{singleTimeName}}</uni-td>
						<uni-td align="center" class='flex-row rightImg'>
								<picker mode="date" :value="dateZW"  @change="bindDateChange">
									<view class="uni-input">
										<text>{{dateZW}}</text>
										<image src="../../../static/images/goright.png" mode="" />
									</view>
								</picker>
						</uni-td>
					</uni-tr>
					<uni-tr>
						<uni-td>现场测量时间</uni-td>
						<uni-td>{{measureTimeName}}</uni-td>
						<uni-td align="center" class='flex-row rightImg'>
							<picker mode="date" :value="dateT"  @change="bindDateChangeT">
								<view class="uni-input">
									<text>{{dateT}}</text>
									<image src="../../../static/images/goright.png" mode="" />
								</view>
							</picker>
						</uni-td>
					</uni-tr>
					<uni-tr style='background-color: rgba(29, 106, 255, 0.0600)'>
						<uni-td>进场安装时间</uni-td>
						<uni-td>{{installTimeName}} </uni-td>
					<uni-td align="center" class='flex-row rightImg'>
						<picker mode="date" :value="dateTh"  @change="bindDateChangeTh">
							<view class="uni-input">
								<text>{{dateTh}}</text>
								<image src="../../../static/images/goright.png" mode="" />
							</view>
						</picker>
					</uni-td>
					</uni-tr>
					<uni-tr>
						<uni-td>订购周期参考</uni-td>
						<uni-td align="center" colspan="2" style='flex-row'>
							<input type="text" placeholder="" v-model="cycle">天
						</uni-td>
					</uni-tr>
					<uni-tr style='background-color: rgba(29, 106, 255, 0.0600)'>
						<uni-td>注意事项(备注)</uni-td>
						<uni-td colspan="2" align="center">
							<input type="text" placeholder="" style="font-size: 28rpx;" v-model="remarks">
						</uni-td>
					</uni-tr>
				</uni-table>
			</view>
			<view class="flex-col items-center button" @click="save"><text class="text_15">保存</text></view>
		</view>
		
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			const currentDate = this.getDate({
					format: true
			})
			return {
				loading: false,
				date: '',
				dateT:'',
				measureTimeName:'',
				dateTh:'',
				installTimeName:'',
				materialName:'',
				remarks:'',
				cycle:'',
				datalist:'',
				item:'',
				dateZW:'',
				singleTimeName:''
			};
		},
		onLoad(option) {
			
		},
		created() {
			
			let item = uni.getStorageSync('item');
			console.log(item)
			this.item = item
			// this.materialName = item.materialName;
			// this.data = item.singleTime;
			// this.dateT = item.measureTime;
			// this.dateTh = item.installTime;
			// this.cycle = item.cycle;
			// this.remarks = item.remarks;
			this.getdata();
			uni.startPullDownRefresh();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			bindDateChange(e) {
					this.dateZW = e.detail.value
			},
			bindDateChangeT(e){
					this.dateT = e.detail.value
			},
			bindDateChangeTh(e){
					this.dateTh = e.detail.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
						year = year - 60;
				} else if (type === 'end') {
						year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
			getdata(){
				let date={
					mobilizationId:this.item.mobilizationId,
				}
				this.$http('common.mobilizationId',date).then(res=>{
					console.log(res,'获取')
					if(res.code==200){
						this.datalist = res.data;
						this.materialName = res.data.materialName;
						this.dateZW = res.data.singleTime;
						this.singleTimeName = res.data.singleTimeName;
						this.dateT = res.data.measureTime;
						this.measureTimeName = res.data.measureTimeName;
						this.dateTh = res.data.installTime;
						this.installTimeName = res.data.installTimeName;
						this.cycle = res.data.cycle;
						this.remarks = res.data.remarks;
					}else{
						uni.showToast({
							icon:"error",
							title:res.msg
						})
					}
				})
			},
			save(){
				let date={
					mobilizationId:this.datalist.mobilizationId,
					durationCalculationId:this.datalist.durationCalculationId,
					projectId:this.datalist.projectId,
					uuid:this.datalist.uuid,
					materialName:this.materialName,
					singleTime:this.dateZW,
					measureTime:this.dateT,
					installTime:this.dateTh,
					cycle:this.cycle,
					remarks:this.remarks
				}
				this.$http('other.updatematerial',date).then(res=>{
					if(res.code==200){
						uni.navigateTo({
							url:'pages/foreman/purchase/purchase'
						})
					}else{
						uni.showToast({
							icon:"error",
							title:res.msg
						})
					}
				})
			}
		},
	};
</script>

<style scoped lang="css">
	.rightImg{
		
	}
	.rightImg image{
		width: 20rpx;
		height: 20rpx;
		margin-left: 20rpx;
	}
	.uni-table-td{
		line-height: 70rpx;
	}
	.uni-group {
		display: flex;
		align-items: center;
	}

	.image_1 {
		width: 14rpx;
		height: 26rpx;
	}

	.page {
		background-color: #ffffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.group {
		padding: 29rpx 32rpx 48rpx;
		flex: 1 1 auto;
		overflow-y: auto;
	}

	.button {
		margin-top: 533rpx;
		padding: 19rpx 0 31rpx;
		background-color: #1d6aff;
		border-radius: 44rpx;
	}

	.text_1 {
		align-self: flex-start;
		color: #1d6aff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
		margin-bottom: 40rpx;
		font-weight: 600;
	}

	.section_1 {
		margin-top: 34rpx;
		padding-left: 32rpx;
		padding-right: 17rpx;
		background-image: url('https://project-user-resource-1256085488.cos.ap-guangzhou.myqcloud.com/617a2ca7e4f1450011362b37/62b14c62d02982001153329a/16557868671170033768.png');
		background-position: 0% 0%;
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.text_15 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.group_2 {
		margin-top: 28rpx;
		flex-shrink: 0;
	}

	.section_2 {
		margin-left: 33rpx;
		flex-shrink: 0;
		background-color: #d9d9d9;
		width: 1rpx;
		height: 436rpx;
	}

	.group_3 {
		margin-left: 32rpx;
		flex: 1 1 auto;
	}

	.text_2 {
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_3 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_4 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_5 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_6 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_14 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_13 {
		margin-top: 24rpx;
		align-self: center;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.group_6 {
		margin-top: 28rpx;
		flex-shrink: 0;
	}

	.section_3 {
		margin-left: 24rpx;
		flex-shrink: 0;
		background-color: #d9d9d9;
		width: 1rpx;
		height: 262rpx;
	}

	.group_7 {
		margin-left: 28rpx;
		margin-right: 4rpx;
		flex: 1 1 auto;
		align-self: center;
	}

	.text_7 {
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_8 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_9 {
		margin-top: 59rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.text_10 {
		align-self: flex-start;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.group_8 {}

	.group_9 {
		margin-top: 30rpx
	}

	.group_11 {
		margin-top: 30rpx
	}

	.group_10 {
		margin-top: 50rpx;
		padding-left: 4rpx;
	}

	.text_11 {
		margin-bottom: 9rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.image_2 {
		margin-left: 29rpx;
		margin-top: 11rpx;
	}

	.text_12 {
		margin-bottom: 9rpx;
		color: #333333;
		font-size: 24rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 28rpx;
	}

	.image_3 {
		margin-left: 11rpx;
		margin-top: 11rpx;
		flex-shrink: 0;
	}
</style>
